function save_data(){
    if($("#upload_title").val()=="" ){
        layer.alert("填个标题吧！");
        return fasle;
    }
    //排序不填默认为0
    if($("#upload_order").val()==""){
        $("#upload_order").val(0);
    }
    //跳转链接不填默认为#
    if($("#upload_url").val()==""){
        $("#upload_url").val("#");
    }
    var index1=layer.load(
        3,
        {shade:[0.5,'#000']}
    )
    
    $.post(
        "controler.php",
        {
            handle:"sava_module_data",
            id:$("#data_id").html(),
            title:$("#upload_title").val(),
            data_order:$("#upload_order").val(),
            url:$("#upload_url").val(),
            img:$("#show_pic").attr("src"),
            content:$("#content_text").val(),
            module:this_module,
        },
        function(msg){
            layer.close(index1);
            result(msg);
        }
    )
}

function dele(id){
    layer.confirm('确定要删除此记录吗？', {icon: 3, title:'提示'}, function(index){
        layer.close(index);
        var index1=layer.load(
            3,
            {shade:[0.5,'#000']}
        )
        $.post(
                "controler.php",
                {
                    handle:"dele_module_data",
                    id:id
                },
                function (msg) 
                {
                    layer.close(index1);
                    result(msg);
            });
        });
}

function result(msg){
    try {
        var data=JSON.parse(msg);
        if(data.code=="done"){
            $(".zhemu").css("display","none");
            check();
        }
        else{
            layer.alert(data.msg);
        }
    } catch(e) {
        layer.alert("请求出错，请稍后再试！");
    }
}
//获取模块信息
function check(){
    var index1=layer.load(
        3,
        {shade:[0.5,'#000']}
    )
    $.post(
            "controler.php",
            {
                handle:"module_data",
                module:this_module
            },
            function (msg) 
            {   layer.close(index1);
                var data=JSON.parse(msg);
                var show_string="";
                //图片式模块输出
                
                if($("."+ this_module).attr("type")=="pic"){
                    for (let index = 0; index < data.length; index++) {
                        show_string=show_string + '<div class="data_div"><div class="data_img"><img src="' + data[index]['img'] + '" ></div><div class="data_title">' + data[index]['title'] + '</div><div class="data_url">' + data[index]['url'] + '</div><div class="data_btn"><button onclick="dele(' + "'" + data[index]['id'] + "'" + ')">删除</button></div><div class="data_btn"><button  onclick="modify_lun(' + "'" + data[index]['id'] + ',' + data[index]['img'] + ',' + data[index]['title'] + ',' + data[index]['data_order'] + ',' + data[index]['url'] + "'" + ')">修改</button></div><div class="data_order">' + data[index]['data_order'] + '</div></div>';
                    }

                    show_string= '<div class="head_div"><button onclick="javascript:add_lun()" >添加新图片</button></div><div class="data"><div class="data_div"       style="height: 30px;"><div class="data_img"   style="line-height: 30px;padding-left: 50px;">图片</div><div class="data_title" style="line-height: 30px;padding:0;">标题</div><div class="data_url" style="line-height: 30px;padding:0;">点击跳转路径</div><div class="data_btn"   style="line-height: 30px;padding:0;">删除</div><div class="data_btn"   style="line-height: 30px;padding:0;">修改</div><div class="data_order" style="line-height: 30px;padding:0;">排序</div></div>'+ show_string +'</div>';
                }
                $("." +this_module).html(show_string);

    });
}